﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SGCG.Helpers
{
    public static class PointExtensions
    {

        public static Point Add(this Point p, Point q)
        {
            return new Point(p.X + q.X, p.Y + q.Y);
        }

        public static Point Subtract(this Point p, Point q)
        {
            return new Point(p.X - q.X, p.Y - q.Y);
        }

        public static double DotProduct(this Point p, Point q)
        {
            return p.X * q.X + p.Y * q.Y;
        }

        public static double CrossProduct(this Point p, Point q)
        {
            return p.X * q.Y - p.Y * q.X;
        }

        public static Point Multiply(this Point p, double r)
        {
            return new Point(p.X * r, p.Y * r);
        }

        public static Point Divide(this Point p, double r)
        {
            return new Point(p.X / r, p.Y / r);
        }

        public static Point Project(this Point p, Point q)
        {
            return q.Multiply(p.DotProduct(q) / q.DotProduct(q));
        }

        public static double Norm(this Point p)
        {
            return Math.Sqrt(p.DotProduct(p));
        }

        public static Point Normalized(this Point p)
        {
            return p.Divide(p.Norm());
        }

    }
}
